/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beanUser;


import com.matrimonysite.entity.UserProfile;
import com.matrimonysite.sessionbean.UserProfileFacade;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;


/**
 *
 * @author khanhnguyen
 */
@ManagedBean (name = "AddProfile")
@SessionScoped
public class AddProfile {
    @EJB
    private UserProfileFacade userProfileFacade;
    private UserProfile userProfile;
    
    List<UserProfile> userProfileList;

    public UserProfile getUserProfile() {
        return userProfile;
    }

    public void setUserProfile(UserProfile userProfile) {
        this.userProfile = userProfile;
    }       
    /**
     * Creates a new instance of AddProfile
     */
    public AddProfile() {
        userProfile = new UserProfile();
        userProfileFacade = new UserProfileFacade();
    }
    public void creatUserProfile(){
        Integer str= userProfile.getProfileID();
        userProfile.getProfileID();
        userProfile.getFirstname();
        userProfile.getMiddleName();
        userProfile.getLastName();
        userProfile.getGender();
        userProfile.getDateOfBirth();
        userProfile.getMaritalStatus();
        userProfile.getHeight();
        userProfile.getCity();
        userProfile.getCountryLiving();
        userProfile.getMotherTongue();
        userProfile.getContactNumber();
        userProfile.getReligion();
        userProfile.getCaste();
        userProfile.getVisited();
        
        //create userprofile
        userProfileFacade.create(userProfile);
    }
    public void editUserProfile(){
        userProfileFacade.edit(userProfile);
        FacesContext face = FacesContext.getCurrentInstance();
        face.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Update Profile Success.", "Update Profile Success."));
    }
    public void deleteUserProfile(){
        Integer str = userProfile.getProfileID();
        userProfile.setProfileID(str);
        userProfileFacade.remove(userProfile);
    }
    
    public List<UserProfile> getAllUserProfile(){
        return userProfileFacade.getAllUserProfile();
    }
}
